#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
#define rep(Ii,Jj,Kk) for(int Ii=(Jj),Ii##_=(Kk);Ii<=Ii##_;Ii++)
#define per(Ii,Jj,Kk) for(int Ii=(Jj),Ii##_=(Kk);Ii>=Ii##_;Ii--)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned uint;
typedef long double db;
#define fir first
#define sec second
#define siz(Aa) ((int)(Aa).size())
#define all(Aa) (Aa).begin(),(Aa).end()
#define ckmx(Aa,Bb) (Aa=max(Aa,Bb))
#define ckmn(Aa,Bb) (Aa=min(Aa,Bb))
struct Qis{
	FILE *I;char B[65536],*p1=B,*p2=B;
	char gc(){return p1==p2&&(p2=(p1=B)+fread(B,1,65536,I),p1==p2)?EOF:*p1++;}
	Qis(FILE *I_):I(I_){}
	template<typename T>void read(T &x){x=0;T f=1;char ch=' ';for(;!isdigit(ch);f=ch=='-'?-1:1,ch=gc());for(;isdigit(ch);x=(x<<1)+(x<<3)+(ch^48),ch=gc());x*=f;}
	template<typename T>Qis& operator>>(T& x){read(x);return *this;}
	Qis&operator>>(char& x){x=' ';for(;x<=' ';)x=gc();return *this;}
	Qis&operator>>(char *x){char c=' ';for(;c<=' ';c=gc());for(;c>' ';*(x++)=c,c=gc());*x=0;return *this;}
	Qis&operator>>(string &x){x="";char c=' ';for(;c<=' ';c=gc());for(;c>' ';x+=c,c=gc());return *this;}
}qin(stdin);
struct Qos{
	FILE *O;char B[65536],*p=B;
	void pc(char x){p-B<65536?*p++=x:(fwrite(B,p-B,1,O),p=B,*p++=x);}
	void flush(){fwrite(B,p-B,1,O);}
	Qos(FILE *O_):O(O_){} ~Qos(){flush();}
	template<typename T>void write(T x){if(x<0){pc('-');if(x<-9)write(-(x/10));pc(48-x%10);}else{if(x>9)write(x/10);pc(48+x%10);}}
	template<typename T>Qos& operator<<(T x){write(x);return *this;}
	Qos&operator<<(const char x){pc(x);return *this;}
	Qos&operator<<(const char *x){for(int i=0;x[i];++i)pc(x[i]);return *this;}
	Qos&operator<<(const string x){for(char c:x)pc(c);return *this;}
}qout(stdout);
const int V=1e6,N=1e6+10,inf=1e9+7;
struct node{
	int ans,l,r;
	friend node operator+(const node&x,const node&y){
		return {min({x.ans,y.ans,y.r-x.l}),max(x.l,y.l),min(x.r,y.r)};
	}
}t[N<<2];
multiset<int> s[N][2];
#define mid ((l+r)>>1)
#define ls (rt<<1)
#define rs (rt<<1|1)
void build(int rt,int l,int r){
	t[rt]={inf,-inf,inf};
	if(l==r) return ;
	build(ls,l,mid);
	build(rs,mid+1,r);
}
void add(int rt,int l,int r,int pos,char opt,int val,int id){
	if(l==r){
		if(opt=='A'){
			s[l][id].insert(val);
		}else{
			s[l][id].erase(s[l][id].find(val));
		}
		if(id==0){
			t[rt].l=s[l][id].empty()?-inf:*prev(s[l][id].end());
		}else{
			t[rt].r=s[l][id].empty()?inf:*s[l][id].begin();
		}
		return ;
	}
	if(pos<=mid) add(ls,l,mid,pos,opt,val,id);
	else add(rs,mid+1,r,pos,opt,val,id);
	t[rt]=t[ls]+t[rs];
}
int que(int rt,int l,int r,int pos,int id){
	if(l==r){
		return id==0?t[rt].l:t[rt].r;
	}
	if(pos<=mid) return que(ls,l,mid,pos,id);
	else return que(rs,mid+1,r,pos,id);
}
signed main(){ios::sync_with_stdio(false),cin.tie(nullptr);
	freopen("stone.in","r",stdin);
	freopen("stone.out","w",stdout);
	build(1,1,V);
	int T;qin>>T;
	while(T--){
		char opt;
		int l,r;
		qin>>opt>>l>>r;
		add(1,1,V,l,opt,r,1);
		add(1,1,V,r,opt,l,0);
		if(t[1].l<t[1].r){
			qout<<que(1,1,V,t[1].l,1)-que(1,1,V,t[1].r,0)<<"\n";
		}else{
			qout<<t[1].ans<<"\n";
		}
	}
return 0;}
/*
*/